﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using rock.DAL;
using rock.UI.common;

namespace rock.UI.contract
{
    public partial class UserControlImportRentContractInfo : UserControl
    {
        public UserControlImportRentContractInfo()
        {
            InitializeComponent();
    
        }
        DalRENT_CONTRACT dal = new DalRENT_CONTRACT();

        private bool SHOW_BUTTON = false;
        public bool _SHOW_BUTTON { get { return SHOW_BUTTON; } set {
            SHOW_BUTTON = value;
            this.button1.Enabled = SHOW_BUTTON;
        } }

        private int CONTRACT_SEQID = 0;
        public int _CONTRACT_SEQID { get { return CONTRACT_SEQID; } set { CONTRACT_SEQID = value; } }

        private int ROOM_SEQID = 0;
        public int _ROOM_SEQID { get { return ROOM_SEQID; } set { ROOM_SEQID = value; } }

        private int CUSTOM_SEQID = 0;
        public int _CUSTOM_SEQID { get { return CUSTOM_SEQID; } set { CUSTOM_SEQID = value; } }

        private Decimal ROOM_SIZE = 0;
        public Decimal _ROOM_SIZE { get { return ROOM_SIZE; } set { ROOM_SIZE = value; } }

        private Decimal CONTRACT_MONEY = 0;
        public Decimal _CONTRACT_MONEY { get { return CONTRACT_MONEY; } set { CONTRACT_MONEY = value; } }

        


        public void inits(int CONTRACT_SEQID, int ROOM_SEQID, int CUSTOM_SEQID)
        {
            _CONTRACT_SEQID = CONTRACT_SEQID;
            _ROOM_SEQID = ROOM_SEQID;
            _CUSTOM_SEQID = CUSTOM_SEQID;
            DataSet ds = dal.getRENT_CONTRACT_DETAILINFO(CONTRACT_SEQID);
            String CONTRACT_NUMBER = (String)ds.Tables[0].Rows[0]["CONTRACT_NUMBER"];
            Decimal RENT_MONEY = (Decimal)ds.Tables[0].Rows[0]["RENT_MONEY"];
            DateTime STOP_DATE = (DateTime)ds.Tables[0].Rows[0]["STOP_DATE"];
            DateTime START_DATE = (DateTime)ds.Tables[0].Rows[0]["START_DATE"];
            String CUSTOM_NAME = (String)ds.Tables[0].Rows[0]["CUSTOM_NAME"];
            String XIAOQU_NAME = (String)ds.Tables[0].Rows[0]["XIAOQU_NAME"];
            String DONG_NAME = (String)ds.Tables[0].Rows[0]["DONG_NAME"];
            String ROOM_NAME = (String)ds.Tables[0].Rows[0]["ROOM_NAME"];
            Decimal ROOM_SIZE = (Decimal)ds.Tables[0].Rows[0]["ROOM_SIZE"];
         
            
            _ROOM_SIZE = ROOM_SIZE;
            _CONTRACT_MONEY = RENT_MONEY;

            this.textBox1XiaoQu.Text = XIAOQU_NAME;
            this.textBox2Dong.Text = DONG_NAME;
            this.textBox3Number.Text = ROOM_NAME;
            this.textBox4StartDate.Text = START_DATE.ToString(StringUtils.YYYYMMDD);
            this.textBox5StopDate.Text = STOP_DATE.ToString(StringUtils.YYYYMMDD);
            this.textBox6Money.Text = RENT_MONEY + "";
            this.textBox7Custom.Text = CUSTOM_NAME;
            this.textBox8ConTractCode.Text = CONTRACT_NUMBER;
            this.textBoxSize.Text = ROOM_SIZE + "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FormSelectContract fsc = new FormSelectContract();
            fsc.selectedOk = selectedOk;
            fsc.ShowDialog(this);

        }
        // public delegate void SelectedOk(int CONTRACT_SEQID , int ROOM_SEQID , int CUSTOM_SEQID);
        public void selectedOk(int CONTRACT_SEQID, int ROOM_SEQID, int CUSTOM_SEQID)
        {
            inits(CONTRACT_SEQID, ROOM_SEQID, CUSTOM_SEQID);
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }


    }
}
